package cn.chia.front.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Component;

import cn.chia.front.dao.ICatagorgyDAO;
import cn.chia.pojo.TblCatagorgy;

@Component
public class CatagorgyDAOImpl extends HibernateDaoSupport implements ICatagorgyDAO {

	@Autowired
	public CatagorgyDAOImpl(HibernateTemplate hibernateTemplate){
		super.setHibernateTemplate(hibernateTemplate);
	}
	
	/**
	 * @author Administrator
	 * @Todo 查询全部一级分类信息
	 * @return
	 */
	public List<TblCatagorgy> getByFirst() {
		String hql = "FROM TblCatagorgy WHERE catagorgyParentId=1";
		Query query = getSession().createQuery(hql);
		List<TblCatagorgy> list = query.list();
		return query.list();
	}
	
	/**
	 * @author Administrator
	 * @param catagorgyId 一级分类对应的id值
	 * @Todo 查询某个一级所对应二级分类信息
	 * @return
	 */
	public List<TblCatagorgy> getBySecond(Integer catagorgyId) {
		String hql = "FROM TblCatagorgy WHERE catagorgyParentId=?";
		Query query = getSession().createQuery(hql);
		query.setInteger(0,catagorgyId);
		return query.list();
	}

}
